﻿@*PayPalStandardPaymentProcessor*@

@if(ViewBag.Mode == "Place")
{
    <div class="hint">
        <p>@T(Res.Of(ViewBag.Mode).Name("Hint"))</p>
    </div>
}
else if(ViewBag.Mode == "Process")
{
    var attrs = (Model.Attributes as IEnumerable<dynamic>);
    string req = String.Format("{0}?cmd={1}&business={2}&paymentaction={3}&upload={4}&item_name={5}" +
        "&amount={6}&invoice={7}&custom={8}&lc={9}&address1={10}&address2={11}&city={12}&country={13}" +
        "&email={14}&zip={15}&rm=2&return={16}",
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "gateway").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "cmd").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "business").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "paymentaction").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "upload").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "item_name").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "amount").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "invoice").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "custom").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "lc").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "address1").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "address2").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "city").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "country").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "email").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "zip").Value),
        Url.Action(Loc.Act("IPN").Ctrl("Payment").Set(new
        {
            handlerID = "87f016ca-2c38-4f1d-b10e-9c896ba58ed5"
        }).Localized().Proto("http")));
    if(!Svc.Config(Par.In("WebPortal").Name("DebugMode"), Context.IsDebuggingEnabled))
    {
        <script type="text/javascript">
            jQuery(document).ready(function () {
                setTimeout(function() {
                    window.location = '@req';
                }, 3000);
            });
        </script>
    }
    <div class="box">
        <section>
            <div class="hint">
                @if(Svc.Config(Par.In("WebPortal").Name("DebugMode"), Context.IsDebuggingEnabled))
                {
                    <p>@req</p>
                }
                <p>@T(Res.Of(ViewBag.Mode).Name("Hint"))</p>
            </div>
        </section>
    </div>
}
else if(ViewBag.Mode == "Details")
{
    var attrs = (Model.Attributes as IEnumerable<dynamic>);
    <div class="hint">
        <p>@T(Res.Of(ViewBag.Mode).Name("Hint"))</p>
        @if(JDM.HasFlags(Model.Flags, "Authorized") || JDM.HasFlags(Model.Flags, "Captured"))
        {
            <ul>
                <li>@T(Res.Of(ViewBag.Mode).Name("Transaction"), JDM.String(attrs.Single(x => JDM.String(x.Key) == "txn_id").Value))</li>
            </ul>
        }
    </div>
}